-- 哈尔滨双城区仓库数据插入脚本
-- 生成1000条仓库记录

-- 清空现有数据（谨慎执行）
-- DELETE FROM wms_warehouse;
-- ALTER TABLE wms_warehouse AUTO_INCREMENT = 1;

-- 开始事务
BEGIN;

-- 插入1000条仓库记录
INSERT INTO wms_warehouse (warehouse_name, warehouse_code, warehouse_type, address, area, capacity, status, create_by, create_time, remark)
VALUES 
-- 第一批：普通仓库 (1-300)
('双城区农产品仓储中心001', 'SC-WH-001', '1', '黑龙江省哈尔滨市双城区东北大街56号', 1200.50, 3600.00, '0', 'admin', NOW(), '双城区标准普通仓库'),
('双城区农产品仓储中心002', 'SC-WH-002', '1', '黑龙江省哈尔滨市双城区西北大街78号', 980.25, 2940.75, '0', 'admin', NOW(), '双城区标准普通仓库'),
('双城区农产品仓储中心003', 'SC-WH-003', '1', '黑龙江省哈尔滨市双城区南岗街道15号', 1050.80, 3152.40, '0', 'admin', NOW(), '双城区标准普通仓库'),
('双城区农产品仓储中心004', 'SC-WH-004', '1', '黑龙江省哈尔滨市双城区北岗街道23号', 1150.60, 3451.80, '0', 'admin', NOW(), '双城区标准普通仓库'),
('双城区农产品仓储中心005', 'SC-WH-005', '1', '黑龙江省哈尔滨市双城区兴隆镇兴隆街12号', 950.30, 2850.90, '0', 'admin', NOW(), '双城区标准普通仓库'),
('双城区农产品仓储中心006', 'SC-WH-006', '1', '黑龙江省哈尔滨市双城区兴隆镇农业路45号', 1080.40, 3241.20, '0', 'admin', NOW(), '双城区标准普通仓库'),
('双城区农产品仓储中心007', 'SC-WH-007', '1', '黑龙江省哈尔滨市双城区万隆镇中心路8号', 1020.70, 3062.10, '0', 'admin', NOW(), '双城区标准普通仓库'),
('双城区农产品仓储中心008', 'SC-WH-008', '1', '黑龙江省哈尔滨市双城区万隆镇工业园区3号', 1180.90, 3542.70, '0', 'admin', NOW(), '双城区标准普通仓库'),
('双城区农产品仓储中心009', 'SC-WH-009', '1', '黑龙江省哈尔滨市双城区周家镇周家大街56号', 990.50, 2971.50, '0', 'admin', NOW(), '双城区标准普通仓库'),
('双城区农产品仓储中心010', 'SC-WH-010', '1', '黑龙江省哈尔滨市双城区周家镇农贸路78号', 1100.20, 3300.60, '0', 'admin', NOW(), '双城区标准普通仓库');

-- 批量插入更多记录 (11-300)
INSERT INTO wms_warehouse (warehouse_name, warehouse_code, warehouse_type, address, area, capacity, status, create_by, create_time, remark)
SELECT 
    CONCAT('双城区普通仓库', LPAD((@row_number:=@row_number+1), 3, '0')),
    CONCAT('SC-WH-', LPAD((@row_number), 3, '0')),
    '1',
    CASE 
        WHEN (@row_number % 5) = 1 THEN CONCAT('黑龙江省哈尔滨市双城区东风街道东风路', @row_number, '号')
        WHEN (@row_number % 5) = 2 THEN CONCAT('黑龙江省哈尔滨市双城区兴隆镇兴农路', @row_number, '号')
        WHEN (@row_number % 5) = 3 THEN CONCAT('黑龙江省哈尔滨市双城区万隆镇工业园区', @row_number, '号')
        WHEN (@row_number % 5) = 4 THEN CONCAT('黑龙江省哈尔滨市双城区周家镇农业发展区', @row_number, '号')
        ELSE CONCAT('黑龙江省哈尔滨市双城区青岭镇青岭大街', @row_number, '号')
    END,
    800 + RAND() * 500,
    2400 + RAND() * 1500,
    '0',
    'admin',
    DATE_ADD(NOW(), INTERVAL -FLOOR(RAND() * 365) DAY),
    '双城区标准普通仓库'
FROM 
    (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION
     SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 UNION SELECT 10) t1,
    (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION
     SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 UNION SELECT 10) t2,
    (SELECT 1 UNION SELECT 2 UNION SELECT 3) t3,
    (SELECT @row_number:=10) t4
LIMIT 290;

-- 第二批：冷库 (301-600)
INSERT INTO wms_warehouse (warehouse_name, warehouse_code, warehouse_type, address, area, capacity, status, create_by, create_time, remark)
SELECT 
    CONCAT('双城区冷藏仓库', LPAD((@row_number:=@row_number+1), 3, '0')),
    CONCAT('SC-CW-', LPAD((@row_number), 3, '0')),
    '2',
    CASE 
        WHEN (@row_number % 5) = 1 THEN CONCAT('黑龙江省哈尔滨市双城区新兴工业园区', (@row_number-300), '号')
        WHEN (@row_number % 5) = 2 THEN CONCAT('黑龙江省哈尔滨市双城区农产品加工区', (@row_number-300), '号')
        WHEN (@row_number % 5) = 3 THEN CONCAT('黑龙江省哈尔滨市双城区冷链物流中心', (@row_number-300), '号')
        WHEN (@row_number % 5) = 4 THEN CONCAT('黑龙江省哈尔滨市双城区食品加工园区', (@row_number-300), '号')
        ELSE CONCAT('黑龙江省哈尔滨市双城区现代农业示范区', (@row_number-300), '号')
    END,
    600 + RAND() * 400,
    1800 + RAND() * 1200,
    '0',
    'admin',
    DATE_ADD(NOW(), INTERVAL -FLOOR(RAND() * 365) DAY),
    '双城区标准冷藏仓库'
FROM 
    (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION
     SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 UNION SELECT 10) t1,
    (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION
     SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 UNION SELECT 10) t2,
    (SELECT 1 UNION SELECT 2 UNION SELECT 3) t3,
    (SELECT @row_number:=300) t4
LIMIT 300;

-- 第三批：恒温库 (601-1000)
INSERT INTO wms_warehouse (warehouse_name, warehouse_code, warehouse_type, address, area, capacity, status, create_by, create_time, remark)
SELECT 
    CONCAT('双城区恒温仓库', LPAD((@row_number:=@row_number+1), 3, '0')),
    CONCAT('SC-TW-', LPAD((@row_number), 3, '0')),
    '3',
    CASE 
        WHEN (@row_number % 5) = 1 THEN CONCAT('黑龙江省哈尔滨市双城区现代农业产业园', (@row_number-600), '号')
        WHEN (@row_number % 5) = 2 THEN CONCAT('黑龙江省哈尔滨市双城区绿色食品加工区', (@row_number-600), '号')
        WHEN (@row_number % 5) = 3 THEN CONCAT('黑龙江省哈尔滨市双城区农产品物流中心', (@row_number-600), '号')
        WHEN (@row_number % 5) = 4 THEN CONCAT('黑龙江省哈尔滨市双城区高新技术开发区', (@row_number-600), '号')
        ELSE CONCAT('黑龙江省哈尔滨市双城区农业科技园区', (@row_number-600), '号')
    END,
    500 + RAND() * 300,
    1500 + RAND() * 900,
    '0',
    'admin',
    DATE_ADD(NOW(), INTERVAL -FLOOR(RAND() * 365) DAY),
    '双城区标准恒温仓库'
FROM 
    (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION
     SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 UNION SELECT 10) t1,
    (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION
     SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9 UNION SELECT 10) t2,
    (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t3,
    (SELECT @row_number:=600) t4
LIMIT 400;

-- 提交事务
COMMIT;

-- 验证插入结果
-- SELECT COUNT(*) FROM wms_warehouse;
-- SELECT * FROM wms_warehouse LIMIT 10; 